// 路由-相关模块
import Vue from 'vue'
import VueRouter from 'vue-router'

// 引入组件
import Home from '@/views/Home'
import Layout from '@/views/Layout'
import Play from '@/views/Play'
import Search from '@/views/Search'

// 使用VueRouter
Vue.use(VueRouter)

// 定义路由规则
const routes = [
  // 路由重定向
  {
    path: '/',
    redirect: '/layout',
  },
  {
    path: '/layout',
    component: Layout,
    redirect: '/layout/home',
    // 二级路由
    children: [
      {
        path: 'home',
        component: Home,
        meta: {
          title:'首页'
        }
      },
      {
        path: 'search',
        component: Search,
        meta: {
          title:'搜索'
        }
      },
    ]
  }
]

// 创建实例
const router =new VueRouter({
  routes
})

// 暴露出去
export default router